
set more off 

cap cd "/GhanaPaper_Governance/ReplicationFiles"

cap use "./Data/pol_baseline_AuditsPaper.dta", clear

foreach var of varlist _all {
	cap replace `var' = . if inlist(`var', 777, 888, 999)
}
****************************************************************************
***TABLE 1
	
*LATEX
lab var gender_respondent "Respondents sex (0 = Male, 1 = Female)"
lab var resp_age "Age at last birthday"
lab var emp_public "Number of years in the public sector"
cap lab var emp_current "Number of years in current job"
lab var emp_elect "Elected to current position"
lab var reelection_el "Eligible for reelection"
lab var reelection_int "Intend to run for reelection"
lab var resp_resident "Number of years living in this district"
lab var party "Affiliated with a political party"

tabulate resp_ed, gen(ed_)
lab var ed_1 "Education: Some basic schooling"
lab var ed_2 "Education: Basic school completed"
lab var ed_3 "Education: Some secondary/high school"
lab var ed_4 "Education: Secondary/high school completed"
lab var ed_5 "Education: Post-secondary qualifications"
lab var ed_6 "Education: Some university"
lab var ed_7 "Education: University completed"
lab var ed_8 "Education: Post-graduate"

eststo clear
estpost summarize gender_respondent resp_age resp_resident ed_* /// 
emp_public emp_elect reelection_el reelection_int party
esttab using "desc_baseline.tex", replace label substitute(# \#) ///
    fragment nomtitle nonumber noobs cells("mean(fmt(a2)) sd min max")


****************************************************************************
***TABLE 2

cap cd "/GhanaPaper_Governance/ReplicationFiles"
cap use "./Data/pol_midline_AuditsPaper.dta", clear


*LATEX
lab var sex_respondent "Respondents sex (0 = Male, 1 = Female)"
lab var resp_age "Age at last birthday"
lab var resp_resident "Number of years living in this district"
*lab var emp_public "B2: Number of years in the public sector"
lab var yrs_job "Number of years in current job"
*lab var emp_elect "B3a: Elected to current position"
*lab var reelection_el "B10: Eligible for reelection"
*lab var reelection_int "B11: Intend to run for reelection"
lab var party "Affiliated with a political party"

destring sex_respondent, force replace
destring resp_resident, force replace
destring resp_age, force replace
destring resp_ed, force replace
destring party, force replace
destring yrs_job, force replace

tabulate resp_ed, gen(ed_)


lab var ed_1 "Education: Basic school completed"
lab var ed_2 "Education: Some secondary/high school"
lab var ed_3 "Education: Secondary/high school completed"
lab var ed_4 "Education: Post-secondary qualifications"
lab var ed_5 "Education: Some university"
lab var ed_6 "Education: University completed"
lab var ed_7 "Education: Post-graduate"

foreach var of varlist _all {
	cap replace `var' = . if inlist(`var', 777, 888, 999)
}

eststo clear
estpost summarize sex_respondent resp_age resp_resident ed_* /// 
yrs_job party
esttab using "desc_midline.tex", replace label substitute(# \#) ///
    fragment nomtitle nonumber noobs cells("mean(fmt(a2)) sd min max")




****************************************************************************
*TABLE 3

cap cd "/GhanaPaper_Governance/ReplicationFiles"
cap use "./Data/pol_endline_AuditsPaper.dta", clear


*LATEX
lab var sex_respondent "Respondents sex (0 = Male, 1 = Female)"
lab var resp_age "Age at last birthday"
lab var resp_resident "Number of years living in this district"
*lab var emp_public "B2: Number of years in the public sector"
lab var yrs_job "Number of years in current job"
*lab var emp_elect "B3a: Elected to current position"
*lab var reelection_el "B10: Eligible for reelection"
*lab var reelection_int "B11: Intend to run for reelection"
lab var party "Affiliated with a political party"

destring sex_respondent, force replace
destring resp_resident, force replace
destring resp_age, force replace
destring resp_ed, force replace
destring party, force replace
destring yrs_job, force replace

tabulate resp_ed, gen(ed_)

lab var ed_1 "Education: No formal schooling"
lab var ed_2 "Education: Some basic schooling"
lab var ed_3 "Education: Basic school completed"
lab var ed_4 "Education: Some secondary/high school"
lab var ed_5 "Education: Secondary/high school completed"
lab var ed_6 "Education: Post-secondary qualifications"
lab var ed_7 "Education: Some university"
lab var ed_8 "Education: University completed"
lab var ed_9 "Education: Post-graduate"

foreach var of varlist _all {
	cap replace `var' = . if inlist(`var', 777, 888, 999)
}

eststo clear
estpost summarize sex_respondent resp_age resp_resident ed_* /// 
yrs_job party
esttab using "desc_endline.tex", replace label substitute(# \#) ///
    fragment nomtitle nonumber noobs cells("mean(fmt(a2)) sd min max")
	